/*
@STI LICENSE
(C) 2006-2008 Universit�t Innsbruck.

This file is part of myOntology.

myOntologyis free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

myOntologyis distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with myOntology.  If not, see <http://www.gnu.org/licenses/>.

@STI LICENSE */
/**
 * 
 */
package org.myontology.db;

import java.io.Serializable;
import java.sql.Connection;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import org.hibernate.CacheMode;
import org.hibernate.Criteria;
import org.hibernate.EntityMode;
import org.hibernate.Filter;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.ReplicationMode;
import org.hibernate.SQLQuery;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.hibernate.stat.SessionStatistics;
import org.hibernate.type.Type;
import org.myontology.controller.LifeCycle;

/**
 * @author <a href="michael.hackl@sti2.at">Michael Hackl</a>
 * Project: Myontology - www.myontology.org
 * STI
 *
 */
public class SessionWrapper implements LifeCycle,Session {

	private final Session session;

	public SessionWrapper(Session session) {
		this.session = session;
	}
	
	/* (non-Javadoc)
	 * @see org.myontology.controller.LifeCycle#clean()
	 */
	public void clean() {
		try {
		session.getTransaction().rollback();
		close();
		}
		catch (Exception w){}
	}

	/* (non-Javadoc)
	 * @see org.myontology.controller.LifeCycle#close()
	 */
	public void finish() {
		session.getTransaction().commit();
		
	}

	/* (non-Javadoc)
	 * @see org.myontology.controller.LifeCycle#init()
	 */
	public void init() {
		session.beginTransaction();
	}

	public Transaction beginTransaction() throws HibernateException {
		return session.beginTransaction();
	}

	public void cancelQuery() throws HibernateException {
		session.cancelQuery();
	}

	public void clear() {
		session.clear();
	}

	public Connection close() {
		try {
			return session.close();
		} catch (Exception e) {
			return null;
		}
	}

	public Connection connection() throws HibernateException {
		return session.connection();
	}

	public boolean contains(Object arg0) {
		return session.contains(arg0);
	}

	public Criteria createCriteria(Class arg0, String arg1) {
		return session.createCriteria(arg0, arg1);
	}

	public Criteria createCriteria(Class arg0) {
		return session.createCriteria(arg0);
	}

	public Criteria createCriteria(String arg0, String arg1) {
		return session.createCriteria(arg0, arg1);
	}

	public Criteria createCriteria(String arg0) {
		return session.createCriteria(arg0);
	}

	public Query createFilter(Object arg0, String arg1)
			throws HibernateException {
		return session.createFilter(arg0, arg1);
	}

	public Query createQuery(String arg0) throws HibernateException {
		return session.createQuery(arg0);
	}

	public Query createSQLQuery(String arg0, String arg1, Class arg2) {
		return session.createSQLQuery(arg0, arg1, arg2);
	}

	public Query createSQLQuery(String arg0, String[] arg1, Class[] arg2) {
		return session.createSQLQuery(arg0, arg1, arg2);
	}

	public SQLQuery createSQLQuery(String arg0) throws HibernateException {
		return session.createSQLQuery(arg0);
	}

	public void delete(Object arg0) throws HibernateException {
		session.delete(arg0);
	}

	public int delete(String arg0, Object arg1, Type arg2)
			throws HibernateException {
		return session.delete(arg0, arg1, arg2);
	}

	public void delete(String arg0, Object arg1) throws HibernateException {
		session.delete(arg0, arg1);
	}

	public int delete(String arg0, Object[] arg1, Type[] arg2)
			throws HibernateException {
		return session.delete(arg0, arg1, arg2);
	}

	public int delete(String arg0) throws HibernateException {
		return session.delete(arg0);
	}

	public void disableFilter(String arg0) {
		session.disableFilter(arg0);
	}

	public Connection disconnect() throws HibernateException {
		return session.disconnect();
	}

	public Filter enableFilter(String arg0) {
		return session.enableFilter(arg0);
	}

	public void evict(Object arg0) throws HibernateException {
		session.evict(arg0);
	}

	public Collection filter(Object arg0, String arg1, Object arg2, Type arg3)
			throws HibernateException {
		return session.filter(arg0, arg1, arg2, arg3);
	}

	public Collection filter(Object arg0, String arg1, Object[] arg2,
			Type[] arg3) throws HibernateException {
		return session.filter(arg0, arg1, arg2, arg3);
	}

	public Collection filter(Object arg0, String arg1)
			throws HibernateException {
		return session.filter(arg0, arg1);
	}

	public List find(String arg0, Object arg1, Type arg2)
			throws HibernateException {
		return session.find(arg0, arg1, arg2);
	}

	public List find(String arg0, Object[] arg1, Type[] arg2)
			throws HibernateException {
		return session.find(arg0, arg1, arg2);
	}

	public List find(String arg0) throws HibernateException {
		return session.find(arg0);
	}

	public void flush() throws HibernateException {
		session.flush();
	}

	public Object get(Class arg0, Serializable arg1, LockMode arg2)
			throws HibernateException {
		return session.get(arg0, arg1, arg2);
	}

	public Object get(Class arg0, Serializable arg1) throws HibernateException {
		return session.get(arg0, arg1);
	}

	public Object get(String arg0, Serializable arg1, LockMode arg2)
			throws HibernateException {
		return session.get(arg0, arg1, arg2);
	}

	public Object get(String arg0, Serializable arg1) throws HibernateException {
		return session.get(arg0, arg1);
	}

	public CacheMode getCacheMode() {
		return session.getCacheMode();
	}

	public LockMode getCurrentLockMode(Object arg0) throws HibernateException {
		return session.getCurrentLockMode(arg0);
	}

	public Filter getEnabledFilter(String arg0) {
		return session.getEnabledFilter(arg0);
	}

	public EntityMode getEntityMode() {
		return session.getEntityMode();
	}

	public String getEntityName(Object arg0) throws HibernateException {
		return session.getEntityName(arg0);
	}

	public FlushMode getFlushMode() {
		return session.getFlushMode();
	}

	public Serializable getIdentifier(Object arg0) throws HibernateException {
		return session.getIdentifier(arg0);
	}

	public Query getNamedQuery(String arg0) throws HibernateException {
		return session.getNamedQuery(arg0);
	}

	public org.hibernate.Session getSession(EntityMode arg0) {
		return session.getSession(arg0);
	}

	public SessionFactory getSessionFactory() {
		return session.getSessionFactory();
	}

	public SessionStatistics getStatistics() {
		return session.getStatistics();
	}

	public Transaction getTransaction() {
		return session.getTransaction();
	}

	public boolean isConnected() {
		return session.isConnected();
	}

	public boolean isDirty() throws HibernateException {
		return session.isDirty();
	}

	public boolean isOpen() {
		return session.isOpen();
	}

	public Iterator iterate(String arg0, Object arg1, Type arg2)
			throws HibernateException {
		return session.iterate(arg0, arg1, arg2);
	}

	public Iterator iterate(String arg0, Object[] arg1, Type[] arg2)
			throws HibernateException {
		return session.iterate(arg0, arg1, arg2);
	}

	public Iterator iterate(String arg0) throws HibernateException {
		return session.iterate(arg0);
	}

	public Object load(Class arg0, Serializable arg1, LockMode arg2)
			throws HibernateException {
		return session.load(arg0, arg1, arg2);
	}

	public Object load(Class arg0, Serializable arg1) throws HibernateException {
		return session.load(arg0, arg1);
	}

	public void load(Object arg0, Serializable arg1) throws HibernateException {
		session.load(arg0, arg1);
	}

	public Object load(String arg0, Serializable arg1, LockMode arg2)
			throws HibernateException {
		return session.load(arg0, arg1, arg2);
	}

	public Object load(String arg0, Serializable arg1)
			throws HibernateException {
		return session.load(arg0, arg1);
	}

	public void lock(Object arg0, LockMode arg1) throws HibernateException {
		session.lock(arg0, arg1);
	}

	public void lock(String arg0, Object arg1, LockMode arg2)
			throws HibernateException {
		session.lock(arg0, arg1, arg2);
	}

	public Object merge(Object arg0) throws HibernateException {
		return session.merge(arg0);
	}

	public Object merge(String arg0, Object arg1) throws HibernateException {
		return session.merge(arg0, arg1);
	}

	public void persist(Object arg0) throws HibernateException {
		session.persist(arg0);
	}

	public void persist(String arg0, Object arg1) throws HibernateException {
		session.persist(arg0, arg1);
	}

	public void reconnect() throws HibernateException {
		session.reconnect();
	}

	public void reconnect(Connection arg0) throws HibernateException {
		session.reconnect(arg0);
	}

	public void refresh(Object arg0, LockMode arg1) throws HibernateException {
		session.refresh(arg0, arg1);
	}

	public void refresh(Object arg0) throws HibernateException {
		session.refresh(arg0);
	}

	public void replicate(Object arg0, ReplicationMode arg1)
			throws HibernateException {
		session.replicate(arg0, arg1);
	}

	public void replicate(String arg0, Object arg1, ReplicationMode arg2)
			throws HibernateException {
		session.replicate(arg0, arg1, arg2);
	}

	public void save(Object arg0, Serializable arg1) throws HibernateException {
		session.save(arg0, arg1);
	}

	public Serializable save(Object arg0) throws HibernateException {
		return session.save(arg0);
	}

	public void save(String arg0, Object arg1, Serializable arg2)
			throws HibernateException {
		session.save(arg0, arg1, arg2);
	}

	public Serializable save(String arg0, Object arg1)
			throws HibernateException {
		return session.save(arg0, arg1);
	}

	public void saveOrUpdate(Object arg0) throws HibernateException {
		session.saveOrUpdate(arg0);
	}

	public void saveOrUpdate(String arg0, Object arg1)
			throws HibernateException {
		session.saveOrUpdate(arg0, arg1);
	}

	public Object saveOrUpdateCopy(Object arg0, Serializable arg1)
			throws HibernateException {
		return session.saveOrUpdateCopy(arg0, arg1);
	}

	public Object saveOrUpdateCopy(Object arg0) throws HibernateException {
		return session.saveOrUpdateCopy(arg0);
	}

	public Object saveOrUpdateCopy(String arg0, Object arg1, Serializable arg2)
			throws HibernateException {
		return session.saveOrUpdateCopy(arg0, arg1, arg2);
	}

	public Object saveOrUpdateCopy(String arg0, Object arg1)
			throws HibernateException {
		return session.saveOrUpdateCopy(arg0, arg1);
	}

	public void setCacheMode(CacheMode arg0) {
		session.setCacheMode(arg0);
	}

	public void setFlushMode(FlushMode arg0) {
		session.setFlushMode(arg0);
	}

	public void setReadOnly(Object arg0, boolean arg1) {
		session.setReadOnly(arg0, arg1);
	}

	public void update(Object arg0, Serializable arg1)
			throws HibernateException {
		session.update(arg0, arg1);
	}

	public void update(Object arg0) throws HibernateException {
		session.update(arg0);
	}

	public void update(String arg0, Object arg1, Serializable arg2)
			throws HibernateException {
		session.update(arg0, arg1, arg2);
	}

	public void update(String arg0, Object arg1) throws HibernateException {
		session.update(arg0, arg1);
	}

}
